<?php
class Editor_publisher extends CI_Controller{
	function index(){
		//分页
		$page = $this->input->get('page');//当前页
		$this->load->model('pageclass');
		$sql = "select * from publishers order by id desc";
		$sql = $this->pageclass->page($sql,$page,22,3);//分页返回的sql
		global $pageIndexBar;
		
		
		//查找内容
		$this->load->model('editor_model');
		$data['sidebar'] = array('editorial','publisher');//
		$data['query'] = $this->editor_model->publisher_view($sql);
		$data['page'] = $pageIndexBar;
		
		
		$this->load->view('header_inc',$data);
		$this->load->view('sidebar_inc');
		$this->load->view('editor_publisher');
	}
	
	function new_publisher(){
		$data['sidebar'] = array('editorial','publisher');
		$data['query'] = '';
		$this->load->view('header_inc',$data);
		$this->load->view('sidebar_inc');
		$this->load->view('editor_publisher_file');
	}
	function modify_publisher($id=''){
		if($id==''){//修改内容验证与执行
			if($this->input->post('id')){
				$this->load->model('editor_model');
				$this->editor_model->modify_publisher();			
			}else{//新建内容的验证与执行
				$this->load->model('editor_model');
				$this->editor_model->new_publisher();
			}
		}else{//载入修改页面
			$this->load->model('editor_model');
			$data['sidebar'] = array('editorial','publisher');
			$data['query'] = $this->editor_model->publisher_file_view($id);
			$this->load->view('header_inc',$data);
			$this->load->view('sidebar_inc');
			$this->load->view('editor_publisher_file');		
		}
	}
	function del_publisher($id){
		$this->load->model('editor_model');
		$this->editor_model->del_publisher($id);
	}
}
